import {defineStore} from "pinia"
import {logout} from "@/api/user/user.js";
import {removeToken} from "@/utils/token.js";
import router from "@/router/index.js";
import {useRouter} from "vue-router"

let $router=useRouter()
let useUserStore = defineStore("userStore", () => {

    async function exitLogin() {
        await logout();
        console.log("退出登录")
        removeToken();
        router.replace("/login")
    }

    return {exitLogin}
})

export default useUserStore;